<template>
  <div class="commentItem">
    <div class="top">
      <div class="left">
        <span>{{ commemt.user.nickname }}</span>
        &nbsp;&nbsp;&nbsp;
        <span>2分钟前</span>
      </div>
      <span @click="replay(commemt)">回复</span>
    </div>
    <!-- 组件递归 -->
    <!-- 因为是递归生成的 所以 每个组件都发出了监听事件，一直往上传递，所以才c1组件监听下面递归组件发出的事件 -->
    <c1 v-if="commemt.parent" :commemt="commemt.parent" @replay="replay"></c1>
    <div class="bottom">{{ commemt.content }}</div>
  </div>
</template>

<script>
export default {
  name: "c1",

  props: {
    commemt: {
      type: Object,
    },
  },
  methods: {
    replay(commemt) {
      this.$emit("replay", commemt);
    },
  },
};
</script>

<style lang="less" scoped>
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
</style>